package com.tom.aop.service.impl;

import com.tom.aop.service.IUserService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

/**
 * @author zx
 * @date 2024-08-31 09:40
 */
@Service
public class UserServiceImp implements IUserService, ApplicationContextAware {

    private ApplicationContext applicationContext;
    @Override
    public Boolean showName() {
        System.out.println("UserService#show");
        // UserServiceImp userServiceProxy = (UserServiceImp) AopContext.currentProxy();
        // userServiceProxy.getAage();

        IUserService userService = applicationContext.getBean(IUserService.class);
        userService.getAage();
        return true;
    }

    @Override
    public Boolean getAage() {
        System.out.println("UserService#getAage");
        return true;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
